[Cocoa] NSTask string encoding problem

Posted by ryyst on Stack Overflow See other posts from Stack Overflow or by ryyst
Published on 2010-03-28T18:09:32Z Indexed on 2010/03/28 18:13 UTC
Read the original article Hit count: 349

Filed under:
|
|

Hi,

In my program, I'm grep-ing via NSTask. For some reason, sometimes I would get no results (even though the code was apparently the same as the command run from the CLI which worked just fine), so I checked through my code and found, in Apple's documentation, that when adding arguments to an NSTask object, "the NSTask object converts both path and the strings in arguments to appropriate C-style strings (using fileSystemRepresentation) before passing them to the task via argv[]" (snip).

The problem is that I might grep terms like "Río Gallegos". Sadly (as I checked with fileSystemRepresentation), that undergoes the conversion and turns out to be "RiÃÅo Gallegos".

How can I solve this?

-- Ry

© Stack Overflow or respective owner

Related posts about nstask

Related posts about encoding